﻿using Flurl.Http;
using Modules.Units;
using Sorting.App.Models;
using Sorting.App.Models.Entity;

namespace Sorting.App.Services;

/// <summary>
/// 任务日志服务
/// </summary>
public class ScanLogService
{



    ServiceApis serviceApis = new ServiceApis();

    /// <summary>
    /// 新增扫描日志
    /// </summary>
    /// <returns></returns>

    public bool PostScanLog(ScanLogDto scanLogDto)
    {

        var res =  serviceApis.PostScanLogApi
                   .WithOAuthBearerToken(AppsettingUnits.Token)
                   .PostJsonAsync(scanLogDto)
                   .ReceiveJson<ResfulModel<bool>>();

        return res.Result.data;
    }




    /// <summary>
    /// 获取扫描日志
    /// </summary>
    /// <returns></returns>
    public List<ScanLogDto> GetScanLog()
    {

        var res = serviceApis.GetScanLogApi
                   .WithOAuthBearerToken(AppsettingUnits.Token)
                   .PostAsync()
                   .ReceiveJson<ResfulModel<List<ScanLogDto>>>();

        return res.Result.data;
    }
    //public async Task<List<ScanLogDto>> GetScanLog()
    //{

    //    var res = await serviceApis.GetScanLogApi
    //               .WithOAuthBearerToken(AppsettingUnits.Token)
    //               .PostAsync()
    //               .ReceiveJson<ResfulModel<List<ScanLogDto>>>();

    //    return res.data;
    //}
    public bool UpdateScanLog(ScanLogDto scanLogDto)
    {

        var res = serviceApis.UpdateScanLogApi
                   .WithOAuthBearerToken(AppsettingUnits.Token)
                   .PostJsonAsync(scanLogDto)
                   .ReceiveJson<ResfulModel<bool>>();

        return res.Result.data;
    }

}